package com.xscha.tableforge.jooq.tables;

import org.jooq.*;
import org.jooq.Record;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import java.time.LocalDateTime;

/**
 * 应用表
 * 用于存储应用的基本信息
 */
public class AppTable extends TableImpl<Record> {

    private static final long serialVersionUID = -1L;

    public static final AppTable APP = new AppTable();

    /** 应用ID */
    public final TableField<Record, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 所属空间ID */
    public final TableField<Record, String> SPACE_ID = createField(DSL.name("space_id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 应用名称 */
    public final TableField<Record, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR.nullable(false), this);
    /** 显示顺序 */
    public final TableField<Record, Double> DISPLAY_ORDER = createField(DSL.name("display_order"), SQLDataType.DOUBLE.nullable(false), this);
    /** 应用图标 */
    public final TableField<Record, String> ICON = createField(DSL.name("icon"), SQLDataType.VARCHAR, this);
    /** 应用架构密码 */
    public final TableField<Record, String> SCHEMA_PASS = createField(DSL.name("schema_pass"), SQLDataType.VARCHAR, this);
    /** 删除时间 */
    public final TableField<Record, LocalDateTime> DELETED_TIME = createField(DSL.name("deleted_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 创建时间 */
    public final TableField<Record, LocalDateTime> CREATED_TIME = createField(DSL.name("created_time"), SQLDataType.LOCALDATETIME(3).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this);
    /** 创建人 */
    public final TableField<Record, String> CREATED_BY = createField(DSL.name("created_by"), SQLDataType.VARCHAR.nullable(false), this);
    /** 最后修改人 */
    public final TableField<Record, String> LAST_MODIFIED_BY = createField(DSL.name("last_modified_by"), SQLDataType.VARCHAR, this);
    /** 最后修改时间 */
    public final TableField<Record, LocalDateTime> LAST_MODIFIED_TIME = createField(DSL.name("last_modified_time"), SQLDataType.LOCALDATETIME(3), this);

    private AppTable() {
        super(DSL.name("app"));
    }

    @Override
    public Schema getSchema() {
        return DSL.schema(DSL.name("public"));
    }

    @Override
    public UniqueKey<Record> getPrimaryKey() {
        return Keys.APP_PKEY;
    }

    @Override
    public AppTable as(String alias) {
        return new AppTable().as(alias);
    }

    @Override
    public AppTable as(Name alias) {
        return new AppTable().as(alias);
    }
} 